<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
<meta name="format-detection"
	content="telephone=no,email=no,date=no,address=no">
<title></title>
<link rel="stylesheet" type="text/css" href="../css/aui.css" />
<link rel="stylesheet" type="text/css"
	href="../css/aui-pull-refresh.css" />
<style type="text/css">
.aui-list .aui-list-item i.aui-iconfont {
	-webkit-align-self: center;
	align-self: center;
	font-size: 18px;
}
</style>
</head>
<body>
	<header class="aui-bar aui-bar-nav aui-bar-warning" id="aui-header">
	<a class="aui-pull-left" onclick="window.history.back(-1);"> <span
		class="aui-iconfont aui-icon-left"></span>
	</a>
	<div class="aui-title">回款记录</div>
	<a class="aui-pull-right"> </a> </header>

	<section class="aui-content">
		<ul class="aui-list aui-media-list" id="nice-articles">
		</ul>
	</section>
	<section class="aui-content" id="list"></section>

</body>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript">
	//初始方法
	$(function() {
		getPage(pageNumber, pageSize);
	});

	//得到选择机会信息的id
	var id = "${param.id}";

	//当前初始页
	var pageNumber = 1;
	//每页显示多少条
	var pageSize = 10;
	var countSize = 0;
	function getPage(pageNumber, pageSize) {
		$
				.ajax({
					url : '${pageContext.request.contextPath}/eraningList.do?page='
							+ pageNumber + '&limit=' + pageSize + '&id=' + id,
					type : "POST",
					dataType : "json",
					success : function(data) {
						var html = "";
						if (data.flag == "1") {
							if (typeof (data.data) != "undefined") {
								var da = data.data;
								var customer = data.customer;
								for (var i = 0; i < da.length; i++) {
									html += '<li class="aui-list-item aui-list-item-middle" tapmode onclick="openDetailed(\'' + da[i].earningRecordId + '\')"><div class="aui-media-list-item-inner"><div class="aui-list-item-inner aui-list-item-arrow"><div class="aui-list-item-text"><div class="aui-list-item-title aui-font-size-14 aui-ellipsis-1">';
							if (da[i].contractNum != null && da[i].contractNum != "") {
								html += da[i].contractNum;
							}
							html += '</div><div class="aui-list-item-right">';
							if (da[i].incomeAmount != null && da[i].incomeAmount != "") {
								html += formatCurrency(da[i].incomeAmount);
							}
							html += '</div></div><div class="aui-list-item-text">日期: '
							if (da[i].takeInterest != null && da[i].takeInterest != "") {
								html += toDate(da[i].takeInterest)
							}
							html += '<div class="aui-list-item-right">负责人:'
							if (da[i].createPeople != null && da[i].createPeople != "") {
								html += da[i].createPeople
							}
							html += "</div></div></div></div></li>";
								}
								//countSize = da.total;
								//复制总记录数
								
								if(data.data.length == 0)
								{
									html = "<p style=\"font-size: 1rem;text-align: center;margin-top: 40%;\">暂无数据</p>";
									$("#nice-articles").removeClass("aui-list");
								}
							} else {
								html = "<p style=\"font-size: 1rem;text-align: center;margin-top: 40%;\">暂无数据</p>";
									$("#nice-articles").removeClass("aui-list");
							}
							//alert(html);
							$("#nice-articles").html(html);
						}
					}
				});
	}

	//打开详细
	function openDetailed(id) {
		window.location.href = "public_client.do?path=client_receivable_record&id="
				+ id;
	}

	function toDate(data) {
		var date = new Date(data);
		var y = date.getFullYear();
		var m = date.getMonth() + 1;
		m = m < 10 ? '0' + m : m;
		var d = date.getDate();
		d = d < 10 ? ('0' + d) : d;
		return y + '-' + m + '-' + d;
	}
	/**
	 *转换金钱100,000.00 
	 */
	function formatCurrency(num) {
		if (num != null && num != "") {
			num = num.toString().replace(/\$|\,/g, '');
			if (isNaN(num))
				num = "0";
			sign = (num == (num = Math.abs(num)));
			num = Math.floor(num * 100 + 0.50000000001);
			cents = num % 100;
			num = Math.floor(num / 100).toString();
			if (cents < 10)
				cents = "0" + cents;
			for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
				num = num.substring(0, num.length - (4 * i + 3)) + ','
						+ num.substring(num.length - (4 * i + 3));
			return (((sign) ? '' : '-') + num + '.' + cents);
		}
	}
</script>
</html>